﻿using BarStockManager.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BarStockManager.DAL
{
    public class DrinkRepository : IDrinkRepository
    {
        BarStockEntities context = new BarStockEntities();
        public IEnumerable<Model.Drink> GetDrinks()
        {
            return context.Drinks.Select(d => new Model.Drink()
            {
                Id = d.Id,
                Name = d.Name,
                Volume = d.Volume ?? 0,
                Price = d.Price ?? 0,
                Cost = d.Cost ?? 0
            });
        }

        public Model.Drink GetDrink(Guid id)
        {
            throw new NotImplementedException();
        }

        public void AddDrink(Model.Drink newDrink)
        {
            context.Drinks.Add(new Drink()
            {
                Id = newDrink.Id,
                Name = newDrink.Name,
                Volume = newDrink.Volume,
                Price = newDrink.Price,
                Cost = newDrink.Cost
            });
        }

        public void UpdateDrink(Guid id, Model.Drink updateDrink)
        {
            throw new NotImplementedException();
        }

        public void DeleteDrink(Guid id)
        {
            throw new NotImplementedException();
        }

        public void Save()
        {
            context.SaveChanges();
        }

        public void Dispose()
        {
            context.Dispose();
        }
    }
}
